﻿@model SimpleForum.Data.Models.Post

<div class="bottom-20 post align-left" style="width:725px;" id="post-@Model.Id">
    <div class="post-body">@Html.Markdown(Model.Body)</div>

    <ul class="post-actions">
        @if (User.Identity.IsAuthenticated && Model.Creator.Email != User.Identity.Name) {
        <li class="trigger">
            <a href="#">report</a>
            <div class="menu report-action">
                @if(Model.Reports.Any(x => x.User.Email == User.Identity.Name)) {
                    <em>you have already reported this</em>
                } else {
                    Html.RenderAction("ReportReasons", "Post");
                    <textarea rows="3" cols="28"></textarea>
                }
            </div>
        </li>
        }

        @if (Model.Creator.Email == User.Identity.Name) {
        <li class="trigger">
            <a href="#">edit</a>
        </li>
        }
                
        @if (Model.Ratings.Any()) {
        <li class="trigger">
            <a class="post-action" href="#">post ratings (@Model.Ratings.Count)</a>
            <div class="menu">
                @{ Html.RenderPartial("~/Views/Post/PostRatings.cshtml", Model.Ratings.GroupBy(xx => xx.RatingName)); }
            </div>
        </li>
        }
        
        @if (User.Identity.IsAuthenticated && !Model.Ratings.Any(x => x.User.Email == User.Identity.Name) && Model.Creator.Email != User.Identity.Name) {
            <div class="post-ratings">@{ Html.RenderAction("Ratings", "Post"); }</div>
        }
    </ul>

    @Html.DisplayFor(x => x.Creator, new { cssclass = "align-right" })
</div>